package com.erji.common.mybatis.config;

import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Random;
import java.util.UUID;

@Configuration
public class MyBatisPlusConfig {


    @Bean
    public IdentifierGenerator identifierGenerator() {
        return entity -> {
            long currentTimeMillis = System.currentTimeMillis();
            int randomInt = new Random().nextInt(1000); // 生成一个随机数，增加唯一性
            return currentTimeMillis * 1000 + randomInt;
        };
    }
}
